#ifndef __OUTPUT_H__
#define __OUTPUT_H__

#include "env.h"
#include "libgen.h"

#define wserPrintLog(n, ...)	{																				\
									time_t wsertime;time(&wsertime);tm* wsertm = localtime(&wsertime);			\
									WServer::Output::__wserPrintMsg(0, "%04d/%02d/%02d %02d:%02d:%02d[%s:%d] ",	\
									wsertm->tm_year+1900, wsertm->tm_mon+1, wsertm->tm_mday,					\
									wsertm->tm_hour, wsertm->tm_min, wsertm->tm_sec,							\
									basename((char*)__FILE__), __LINE__);										\
									WServer::Output::__wserPrintMsg(0, n, ##__VA_ARGS__);						\
									WServer::Output::__wserPrintMsg(2, "%04d/%02d/%02d %02d:%02d:%02d[%s:%d] ",	\
									wsertm->tm_year+1900, wsertm->tm_mon+1, wsertm->tm_mday,					\
									wsertm->tm_hour, wsertm->tm_min, wsertm->tm_sec,							\
									basename((char*)__FILE__), __LINE__);										\
									WServer::Output::__wserPrintMsg(2, n, ##__VA_ARGS__);						\
								}

#define wserPrintErr(n, ...)	{																				\
									time_t wsertime;time(&wsertime);tm* wsertm = localtime(&wsertime);			\
									WServer::Output::__wserPrintMsg(1, "%04d/%02d/%02d %02d:%02d:%02d[%s:%d] ",	\
									wsertm->tm_year+1900, wsertm->tm_mon+1, wsertm->tm_mday,					\
									wsertm->tm_hour, wsertm->tm_min, wsertm->tm_sec,							\
									basename((char*)__FILE__), __LINE__);										\
									WServer::Output::__wserPrintMsg(1, n, ##__VA_ARGS__);						\
									WServer::Output::__wserPrintMsg(2, "%04d/%02d/%02d %02d:%02d:%02d[%s:%d] ",	\
									wsertm->tm_year+1900, wsertm->tm_mon+1, wsertm->tm_mday,					\
									wsertm->tm_hour, wsertm->tm_min, wsertm->tm_sec,							\
									basename((char*)__FILE__), __LINE__);										\
									WServer::Output::__wserPrintMsg(2, n, ##__VA_ARGS__);						\
								}

#define wserPrintMsg(n, ...)	{																				\
									time_t wsertime;time(&wsertime);tm* wsertm = localtime(&wsertime);			\
									WServer::Output::__wserPrintMsg(2, "%04d/%02d/%02d %02d:%02d:%02d[%s:%d] ",	\
									wsertm->tm_year+1900, wsertm->tm_mon+1, wsertm->tm_mday,					\
									wsertm->tm_hour, wsertm->tm_min, wsertm->tm_sec,							\
									basename((char*)__FILE__), __LINE__);										\
									WServer::Output::__wserPrintMsg(2, n, ##__VA_ARGS__);						\
								}

namespace WServer {
namespace Output {
void wserInitOutput();
void __wserPrintMsg(int index, const char*, ...);
void wserUninitOutput();
}
}

#endif //__OUTPUT_H__
